#@head() 
#@header()
<title>添加记录</title>
#@aside(menu="calllog")
<div class="content-wrapper">
    <!-- Main content -->
    <section class="content">
      <div class="row">
        <!-- right column -->
        <div class="col-md-12">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title">添加通话记录</h3>
            </div>
            <!-- /.box-header --> 
            <!-- form start -->
            <form class="form-horizontal" method="post" action="#(path)/client/startAdd">
              <div class="box-body">
				<input type="hidden" name="calllog.id"  />
				<div class="form-group">
					<label for="inputEmail3" class="col-sm-2 control-label">姓名</label>
					<div class="col-sm-10">
						<select  id="clientid" class="col-sm-12"></select>
					</div>
				</div>
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-2 control-label">手机号码</label>
					<div class="col-sm-10">
						<input type="text" id="phone" name="calllog.phone" class="form-control"  placeholder="号码" />
					</div>
				</div>
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-2 control-label">是否接通</label>
					<div class="col-sm-10">
						<select name="calllog.isconnect" class="form-control">
							<option value="1">接通</option>
							<option value="0">未接通</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-2 control-label">呼入/呼出</label>
					<div class="col-sm-10">
						<select name="calllog.isconnect" class="form-control">
							<option value="1">呼入</option>
							<option value="2">呼出</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-2 control-label">备注</label>
					<div class="col-sm-10">
						<input type="text" id="phone" name="calllog.phone" class="form-control"  placeholder="号码" />
					</div>
				</div>
              </div>
              <!-- /.box-body -->
              <div class="box-footer">
                <button type="submit" class="btn btn-info center-block">写好了</button>
              </div>
              <!-- /.box-footer -->
            </form>
          </div>
          <!-- /.box -->
        </div>
        <!--/.col (right) -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
  </div>
#@footer()
<script>
$(function(){ 	
	#if(client!=null)
    	// 初始化信息
    $('#clientid').html('<option value="#(client.id)"> #(client.realname)</option>').trigger("change");
    #end
    	
	$("#clientid").on('change keyup',function(){
		ajax("#(path)/client/findById",{"id":$("#clientid").val()},function(data){
            $('#phone').empty();
            $('#phone').val(data.phone);
		});
	});
		
     $("#clientid").select2({
             ajax: {
                 url: "#(path)/client/search",
                 dataType: 'json',
                 delay: 250,
                 data: function(params) {
                     return {
                         key: params.term
                     };
                 },
                 processResults: function(data, params) {
                    
                     return {
                         results: data
                     };
                 },
                 cache: true
             },
             minimumInputLength: 1
      });
    });
    </script>
</body>
</html>